package com.xh.validation;

import com.xh.anno.SellState;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author 黄立恒
 * @version 1.0
 */
public class SellStateValidation implements  ConstraintValidator<SellState,String> {
/**
 *
 * @param value 将来要校验的数据
 * @param context context in which the constraint is evaluated
 *
 * @return 如果返回false,则校验不通过,如果返回true,则校验通过
 */
@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
        //提供校验规则
        if (value == null){
        return false;
        }
        if (value.equals("已出售") || value.equals("未出售")){
        return true;
        }
        return false;
        }
}
